/**
 * A Tool is an object that handles the user input (mouse and keyboard)
 * to change the selection and/or the drawing.
 * 
 * A DrawingArea provides a list of available Tools, 
 * and it always has exactly one current Tool.
 * The current Tool receives all the mouse and keyboard events.
 * 
 * The DrawingFrame creates buttons representing the tool in the toolbar,
 * so that the user can select one of the tools.
 * 
 * @author  Giuseppe Mendola (giuseppe.mendola@usi.ch);Gregory Banfi (gregory.banfi@usi.ch);
 */

// comment

package ch.usi.inf.pf2.gui;

import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;

import javax.swing.ImageIcon;
import javax.swing.Icon;

import ch.usi.inf.pf2.Gates.Gate;
import ch.usi.inf.pf2.pins.InputPin;
import ch.usi.inf.pf2.pins.OutputPin;

public abstract class Tool implements MouseListener, MouseMotionListener,
		KeyListener {

	private final Model model;
	private final String name;
	private final Icon icon;
	public ArrayList<InputPin> inputPins;
	private OutputPin outputPin;

	public Tool(final Model model, final String name, final String iconName) {
		this.model = model;
		this.name = name;
		icon = new ImageIcon(getClass().getResource(iconName));
		inputPins = new ArrayList<InputPin>();
	}

	/**
	 * Those are all accessors methods, used by the subclasses to have access to
	 * the Tool fields.
	 * 
	 * @return
	 */
	public ArrayList<InputPin> getInputPins() {
		return inputPins;
	}

	public OutputPin getOutputPin() {
		return outputPin;
	}

	public String getName() {
		return name;
	}

	public Icon getIcon() {
		return icon;
	}

	protected final Model getModel() {
		return model;
	}

	protected final Selection getSelection() {
		return Model.getSelection();
	}

	protected final Drawing getDrawing() {
		return Model.getDrawing();
	}
	
	protected final ArrayList<Gate> getGates() {
		Model.getDrawing();
		return Drawing.getGates();
	}

	/**
	 * Those methods are all event listeners. They are passes to the subclass
	 * that implement the tool class.
	 */
	@Override
	public void mouseClicked(MouseEvent e) {
	}

	@Override
	public void mouseEntered(MouseEvent e) {
	}

	@Override
	public void mouseExited(MouseEvent e) {
	}

	@Override
	public void mousePressed(MouseEvent e) {
	}

	@Override
	public void mouseReleased(MouseEvent e) {
	}

	@Override
	public void mouseDragged(MouseEvent e) {
	}

	@Override
	public void mouseMoved(MouseEvent e) {
	}

	@Override
	public void keyPressed(KeyEvent e) {
	}

	@Override
	public void keyReleased(KeyEvent e) {
	}

	@Override
	public void keyTyped(KeyEvent e) {
	}
}
